package com.ruoyi.web.controller.api;

import com.ruoyi.common.core.domain.AjaxResult;
//import jdk.jfr.internal.jfc.model.UserInterface;
import com.ruoyi.system.domain.Exguide;
import com.ruoyi.system.domain.News;
import com.ruoyi.system.service.impl.ExguideServiceImpl;
import com.ruoyi.system.service.impl.NewsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//解决跨域
@RestController
//请求路径方法
@CrossOrigin
@RequestMapping("/api")
public class wxActivityController {

    @Autowired
    NewsServiceImpl newsService;

    //    写方法 HTTP GET POT
//    1.响应前端请求展示
    @RequestMapping("/NewsList")
    public AjaxResult showAllActivities() {
//        查询数据库
        News news = new News();
        List<News> newsList = newsService.selectNewsList(news);
        if (newsList.isEmpty()) {
            return AjaxResult.error();
        } else {
            return AjaxResult.success(newsList);
        }
    }

    @RequestMapping("/ActivityReport")
    public AjaxResult wxActivityReport(@RequestParam String nickname,@RequestParam Integer phone,
                                       @RequestParam String addr){
//        保证可以接收到数据，POST请求
        System.out.println(nickname);
//        将报名信息添加进数据库
        wxReport report = new wxReport();
        report.getNickname();
        report.getPhone();
        report.getAddr();
//        如果添加成功，就返回success,否则返回error
    return AjaxResult.success();
    }
}

